<div class="row">
  <div class="col-md-6">

    <div class="card card-primary">
      <div class="card-header">
        <span>Withdraw</span>
      </div>
      <div class="card-body">
        <%= description_for :withdraw do %>
          <%= item_for @withdraw, :id %>
          <%= item_for @withdraw, 'Txid' do %>
            <% if @withdraw.txid? %>
              <a href="<%= @withdraw.transaction_url %>" target="_blank">
                <code class="text-info"><%= @withdraw.txid %></code>
              </a>
            <% else %>
              <%= 'Empty' %>
            <% end %>
          <% end %>
          <%= item_for @withdraw, :created_at %>
          <%= item_for @withdraw, 'State' do %>
            <%= @withdraw.aasm_state.humanize %>
          <% end %>
          <hr class="split">
          <%= item_for @withdraw.member, :email %>
          <%= item_for @withdraw, 'Recipient ID' do %>
            <span><%= @withdraw.rid %></span>
          <% end %>
          <%= item_for @withdraw, :amount %>
          <hr>
          <% if @withdraw.may_accept? || @withdraw.may_process? || @withdraw.confirming? %>
            <ul class="list-inline w-100 px-3 mt-3 pt-3 border-top">
              <%= form_tag admin_withdraw_path(event: 'load'), method: 'PATCH' do -%>
                <%= text_field_tag :txid, nil, placeholder: 'Set txid here...', class: 'form-control w-50 d-inline ml-4' %>
                <%= submit_tag 'Load withdraw', class: 'btn btn-primary float-left' %>
              <% end -%>
            </ul>
          <% end %>
          <ul class="list-inline w-100 px-3 mt-3 pt-3 border-top">
            <% if @withdraw.may_reject? %>
              <li>
                <%= link_to 'Reject',
                            admin_withdraw_path(@withdraw.currency.code, @withdraw),
                            class:   'btn btn-danger float-right',
                            method:  'DELETE' %>
              </li>
            <% end %>
            <% if @withdraw.may_accept? || @withdraw.may_process? %>
              <li>
                <%= link_to 'Process',
                            admin_withdraw_path(event: 'process'),
                            class: 'btn btn-primary float-left',
                            method: 'PATCH' %>
              </li>
            <% end %>
          </ul>
        <% end %>
      </div>
    </div>
  </div>

  <div class="col-md-6">
    <%= render partial: 'shared/admin/member', locals: {member: @withdraw.member} %>
    <%= render partial: 'shared/admin/account', locals: {account: @withdraw.account} %>
  </div>
</div>
